package com.xywl.escort.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xywl.escort.R;
import com.xywl.escort.bean.PurchaseOrderDetailBean;
import com.xywl.escort.widget.GlideApp;

import java.util.List;

/**
 * Created by 32422 on 2018/5/4.
 */

public class PurchaseOrderListAdapter extends BaseQuickAdapter<PurchaseOrderDetailBean.OrderItemsBean, BaseViewHolder> {
    public PurchaseOrderListAdapter(int layoutResId, @Nullable List<PurchaseOrderDetailBean.OrderItemsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PurchaseOrderDetailBean.OrderItemsBean item) {
        ImageView imageView = helper.getView(R.id.img_purchase);
        GlideApp.with(mContext)
                .load(item.imageUrl)
                .centerCrop()
                .placeholder(R.mipmap.icon_default_picture)
                .into(imageView);

        helper.setText(R.id.text_title, item.spuName);
        helper.setText(R.id.text_content, item.skuName);
        if (null != item.originalPrice) {
            String originalPrice = "￥:" + item.originalPrice.doubleValue();
            helper.setText(R.id.text_old_price, originalPrice);
        }
        if (null != item.price) {
            String price = "￥:" + item.price.doubleValue();
            helper.setText(R.id.text_price, price);
        }
        String skuTotal = "X" + item.skuTotal;
        helper.setText(R.id.text_num, skuTotal);
    }
}
